北京邮电大学学报

  • EI核心期刊

北京邮电大学学报 ›› 2006, Vol. 29 ›› Issue (3): 86-90.doi: 10.13190/jbupt.200603.86.lih

• 研究报告 • 上一篇    下一篇

利用基本文法改写模式解决语法分析冲突

李 虎, 金茂忠, 刘 超, 许 福   

  1. 北京航空航天大学 软件工程研究所, 北京 100083
  • 收稿日期:2005-04-27 修回日期:1900-01-01 出版日期:2006-06-30 发布日期:2006-06-30
  • 通讯作者: 李 虎

Resolving Parsing Conflicts by Basic Rules and Patterns of Grammar Rewriting

LI Hu, JIN Mao-zhong, LIU Chao, XU Fu   

  1. Software Engineering Institute, Beihang University, Beijing 100083, China
  • Received:2005-04-27 Revised:1900-01-01 Online:2006-06-30 Published:2006-06-30
  • Contact: LI Hu

摘要:

分析了LALR(1)分析器生成系统中语法分析冲突问题的起因和解决冲突的时机及策略,提出改写文法应遵循的4条规则,将常用的文法改写技巧总结为7个基本的文法改写模式。应用案例表明,提出的文法改写规则和基本文法改写模式可有效解决语法分析冲突。

关键词: LALR(1), 语法分析器生成器, YACC, 语法分析冲突, 文法改写, 消歧

Abstract:

The paper analyzed the origin of the problem of parsing conflicts when using LALR(1) parser generators, and summarized the moments as well as methods to eliminate conflicts in compiling phases. Four basic rules of grammar rewriting as well as seven basic grammar rewriting patterns for the purpose of resolving conflicts were proposed. Case studies show that the proposed techniques are highly effective in developing conflict-free parsers.

Key words: LALR(1), parser generator, yet another compiler’s compiler, parsing conflict, grammar rewriting, disambiguation

中图分类号: